package com.main.tabletobean;

import java.io.File;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.main.util.StringUtil;

/**
 * 模板的一些数据
 * @author Cobbage
 */
public class MyFreeMarkTemplate {

	private Logger log=LoggerFactory.getLogger(this.getClass());
	
	private String classPath;
	private String jspPath;
	//0.表的名称
	private String tableName;
	private String tablePKSeq;
	//1. 首先输入的是Bean的name然后自动匹配出其他Name;
	private String beanName;
	private String daoName;
	private String serviceName;
	private String controllerName;
	private String jspName;
	
	//2.包路径 也是由bean包直接带出的 bean是以bean结尾的包
	private String packageBean;
	private String packageDao;
	private String packageService;
	private String packageConlroller;
	
	//3.注解名称
	private String anoBean;
	private String anoDao;
	private String anoService;
	private String anoController;
	
	//4.列的属性
	private List<ColumnModel> columnList;
	
	public String getBeanName() {
		return beanName;
	}
	public void setBeanName(String beanName) {
		this.beanName = StringUtil.getFirstUp(beanName);
		this.daoName=StringUtil.getFirstUp(beanName+"Dao");
		this.serviceName=StringUtil.getFirstUp(beanName+"Service");
		this.controllerName=StringUtil.getFirstUp(beanName+"Controller");
		log.info("声称类名称bean={},dao={},service={},controller={}",this.beanName,this.daoName,this.serviceName,this.controllerName);
		this.anoBean=StringUtil.getFirstLow(this.beanName);
		this.anoDao=StringUtil.getFirstLow(this.daoName);
		this.anoService=StringUtil.getFirstLow(this.serviceName);
		this.anoController=StringUtil.getFirstLow(this.controllerName);
		this.jspName=StringUtil.getFirstUp(beanName)+"Manager";
	}
	public String getDaoName() {
		return daoName;
	}
	public void setDaoName(String daoName) {
		this.daoName = daoName;
	}
	public String getServiceName() {
		return serviceName;
	}
	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}
	public String getControllerName() {
		return controllerName;
	}
	public void setControllerName(String controllerName) {
		this.controllerName = controllerName;
	}
	public String getPackageBean() {
		return packageBean;
	}
	public void setPackageBean(String packageBean) {
		if(null!=packageBean&&packageBean.endsWith(".bean")){
			this.packageBean = packageBean;
			int index= packageBean.indexOf(".bean");
            this.packageDao=packageBean.substring(0,index)+".dao";
            this.packageService=packageBean.substring(0, index)+".service";
            this.packageConlroller=packageBean.substring(0, index)+".controller";
            log.info("生成bean包路径={},dao包路径={},service包路径={},contoller包路径={}",this.packageBean,this.packageDao,this.packageService,this.packageConlroller);
		}else{
			log.error("包路径不符合规则{}",packageBean);
		}
	}
	public String getPackageDao() {
		return packageDao;
	}
	public void setPackageDao(String packageDao) {
		this.packageDao = packageDao;
	}
	public String getPackageService() {
		return packageService;
	}
	public void setPackageService(String packageService) {
		this.packageService = packageService;
	}
	public String getPackageConlroller() {
		return packageConlroller;
	}
	public void setPackageConlroller(String packageConlroller) {
		this.packageConlroller = packageConlroller;
	}
	public List<ColumnModel> getColumnList() {
		return columnList;
	}
	public void setColumnList(List<ColumnModel> columnList) {
		this.columnList = columnList;
	}
	public String getTableName() {
		return tableName;
	}
	public void setTableName(String tableName) {
		this.tableName = tableName.toUpperCase();
	}
	public String getAnoBean() {
		return anoBean;
	}
	public void setAnoBean(String anoBean) {
		this.anoBean = anoBean;
	}
	public String getAnoDao() {
		return anoDao;
	}
	public void setAnoDao(String anoDao) {
		this.anoDao = anoDao;
	}
	public String getAnoService() {
		return anoService;
	}
	public void setAnoService(String anoService) {
		this.anoService = anoService;
	}
	public String getAnoController() {
		return anoController;
	}
	public void setAnoController(String anoController) {
		this.anoController = anoController;
	}
	public String getTablePKSeq() {
		return tablePKSeq;
	}
	public void setTablePKSeq(String tablePKSeq) {
		this.tablePKSeq = tablePKSeq.toUpperCase();
	}
	public String getJspName() {
		return jspName;
	}
	public void setJspName(String jspName) {
		this.jspName = jspName;
	}
	public String getClassPath() {
		return classPath;
	}
	public void setClassPath(String classPath) {
		if(!StringUtil.isNull(classPath)){
			classPath=classPath.replace("\\", "/");
			if(!classPath.endsWith("/")&&!classPath.endsWith(File.separator)){
				classPath+=File.separator;
			}
			this.classPath = classPath;
		}
	}
	public String getJspPath() {
			return jspPath;
	}
	public void setJspPath(String jspPath) {
		if(!StringUtil.isNull(jspPath)){
			jspPath=jspPath.replace("\\", "/");
			if(!jspPath.endsWith("/")&&!jspPath.endsWith(File.separator)){
				jspPath+=File.separator;
			}
			this.jspPath = jspPath;
		}
	}
	
}
